package com.fzrskj.cloud.free.thridparty.pay.wechat;

import com.fzrskj.cloud.free.core.enums.DicParamEnum;
import com.fzrskj.cloud.free.core.enums.PayWayEnum;
import com.fzrskj.cloud.free.core.utils.CloudContextUtils;
import com.fzrskj.cloud.free.dic.utils.DicParamUtils;
import com.winiis.component.pay.wechat.service.WechatPayInit;

/**
 * WechatPayConfig.
 *
 * @author zj.
 *         Created on 2018/12/28 0028.
 */
public class WechatPayConfig implements WechatPayInit {
    private Integer fromAgentId;
    public WechatPayConfig() {
        this.fromAgentId = CloudContextUtils.getAgentId();
        String way = DicParamUtils.getParamValue(PayWayEnum.WECHAT.getKey());
        if ("99".equals(way)) {
            this.fromAgentId = DicParamUtils.getLastSelfPayParent(PayWayEnum.WECHAT.getKey(), this.fromAgentId);
        }
    }
    @Override
    public String getAppId() {
        return DicParamUtils.getParamValue(DicParamEnum.WECHAT_PAY_APP_ID.getVal(), this.fromAgentId);
    }

    @Override
    public String getMchId() {
        return DicParamUtils.getParamValue(DicParamEnum.WECHAT_PAY_MCH_ID.getVal(), this.fromAgentId);
    }

    @Override
    public String getKey() {
        return DicParamUtils.getParamValue(DicParamEnum.WECHAT_PAY_KEY.getVal(), this.fromAgentId);
    }

    @Override
    public String getSecret() {
        return DicParamUtils.getParamValue(DicParamEnum.WECHAT_PAY_APP_SECRET.getVal(), this.fromAgentId);
    }
}
